package com.five.wisdomEat.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.five.wisdomEat.entity.Application;
import com.five.wisdomEat.entity.Business;
import com.five.wisdomEat.entity.BusinessInfo;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface BusinessMapper extends BaseMapper<Business> {
    //查询商家信息，是否入驻
    @Select("SELECT b.*,s.s_name FROM business b INNER JOIN settled s ON b.settledId = s.id WHERE b_Number = #{bNumber}")
    List<Business> selectBusinessList(String bNumber);

    //查询商家是否能够登录成功
    @Select("SELECT COUNT(*) FROM business WHERE b_Number = #{bNumber} AND password = #{password}")
    Integer businessLogin(Business business);

    //将商家修改为入驻
    @Update("UPDATE business SET settledId=1 WHERE b_Number = #{bNumber}")
    Integer businessJoin(String bNumber);
    //商家注册账号
    @Insert("INSERT INTO login_table " +
            "(id,s_number,teacher_number,business_number,phone,password,name,avatar,type) " +
            "VALUES (null,null,null,#{bNumber},#{bPhone},#{bPassword},#{bName},null,6)")
    Integer businessReg(String bNumber, String bPhone, String bPassword, String bName); //添加到登陆表
    @Insert("INSERT INTO business " +
            "(id,b_number,password,avatar,type,settledId) " +
            "VALUES (null,#{bNumber},#{password},null,#{type},2)")
    Integer addBusiness(Business business); //添加到商家入驻状态表
    @Insert("INSERT INTO businessinfo (id,b_number,b_name,b_address,b_phone,b_status) " +
            "VALUES (null,#{bNumber},#{bName},#{bAddress},#{bPhone},2)")
    Integer addBusinessinfo(BusinessInfo businessInfo);//添加到商家信息表


}
